package com.rectcircle.dao

import com.rectcircle.db.BookDb
import com.rectcircle.model.{Author, Book}


object BookDao{
	
	def save(b:Book):Book = {
		BookDb.save(b)
	}
	
	def getBooksByAuthorName(name:String):Vector[Book] = {
		BookDb.findByAuthorName(name).toVector
	}
	
	def getBooksWithAuthorByName(name:String):Vector[(Book,Author)] ={
		BookDb.findWithAuthorByBookName(name).toVector
	}
	
	def getBooksByAuthorAndPage(author: Author, offset:Int, pageLength:Int):Vector[Book] = {
		BookDb.findBooksByAuthorAndPage(author,offset,pageLength).toVector
	}
	
	def withAuthor(book: Book) = {
		BookDb.withAuthor(book)
	}
	
	def withReaders(book: Book) = {
		BookDb.withReaders(book)
	}
	
	
}